$(document).ready(function(){
    // 展示左侧的文档目录
    var eCateContainer = $('#cateContainer'), eArticleTitle = $('#articleTitle');
    eCateContainer.append(getDocCate(cate, did));
    eCateContainer.find('a[cid="'+cid+'"]').addClass('act');
    if(eArticleTitle.text() == ''){
        eArticleTitle.text(eCateContainer.find('.act').text());
    }
    setDocCount('#cateContainer>ul>li');
    // 实现上一页和下一页功能
    setPrevNext(eCateContainer.find('a'), cid);
    // 切换显示/隐藏左侧的目录部分
    var eCateBtn = $('#cateBtn'), eCateSec = $('#cateSec'), eArticleSec = $('#articleSec');
    eCateBtn.click(function(){
        if(eCateSec.hasClass('hide')){
            eCateSec.removeClass('hide');
            eArticleSec.addClass('with-cate');
        }else{
            eCateSec.addClass('hide');
            eArticleSec.removeClass('with-cate');
        }
    });
    var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
    if(width < 580){
        eCateBtn.click();
    }
    // 实现分享按钮功能
    var shareUrl = 'http://www.jiathis.com/send/?webid=';
    var shareStr = '&url=http://doc.wooo.wang/d/'+did+'/c/'+cid+'.html&title='+docName+' - '+articleName+' - 我网[wooo.wang]，分享与收获知识、经验、见解的团体协作书写平台！';
    $('#shareQQ').attr('href', shareUrl+'qzone'+shareStr);
    $('#shareWeibo').attr('href', shareUrl+'tsina'+shareStr);
    $('#shareWeixin').attr('href', shareUrl+'weixin'+shareStr);

    /*
    var clock=window.setInterval(function(){
        if(parseInt(new Date().getTime()/1000)>deadline){
            $('.sendTip').html('<span>当前可书写</span>');
            $('.md-button').removeClass('no-save');
            clearInterval(clock);
        }else{
            $('.sendTip').html('<span class="red">当前不可书写 倒计时：'+(deadline-parseInt(new Date().getTime()/1000))+'s</span>');
        }
    },1000);

    if($('body').width()<=580) $('.cate-onOff').click();

    $('#full').click(fullScreen);
    // 使用鼠标选中一段文字的功能
    var txt;
    $('.book-main>.wooo').mouseup(function(e){
        if(document.selection){
            txt = document.selection.createRange().text;
        }else{
            txt = window.getSelection()+'';
        }
        if(txt){
            $('body').append('<a href="#newQuestion" class="questionBtn"><span class="icon-weixin" title="提出问答？"></span></a>');
            $('.questionBtn').css({'top':e.pageY-34,'left':e.pageX-28});
        }else{
            if($('.questionBtn').length) $('.questionBtn').remove();
        }
    });
    $('body').on('click','.questionBtn',function(){
        $('.questionBtn').remove();
        $('.formContent').focus().val('> '+txt);
        var m=setTimeout(function(){
            $('.formTitle').focus();
        },400);
    });
    */
});